package cn.nb12.xbox.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.stereotype.Component;

/**
 * 生成业务编号(时间精确到秒加6位流水号),String doWork(null)
 * @author 
 *
 */
@Component
public class GenerateBusinessCodeService{
	private int i=0; 
	public String doWork() {
		String s=new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
		synchronized (GenerateBusinessCodeService.class) {
			i++;
			if(i>=999999){ 
				i=0;
			}
			s=String.format("%s%06d", s, i);
		}
		return s;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(new GenerateBusinessCodeService().doWork());
	}

}
